import { Layout } from 'antd';
import React from 'react'
import { Route,Redirect} from 'react-router-dom';
import { hasToken} from '@/utils/storage';


export default function PrivateRoute({children,component,...rest}) {
  return (
    <Route {...rest}  render = {({ location }) => {
      if(hasToken()){
        return children?children:component
      }else{
        // return history.push('/login')
        return <Redirect  to={{
                      pathname: "/login",
                      state: { from: location.pathname }
                    }}
              ></Redirect>
      }
    }} ></Route>
  )
}
